package javaClassExercise;

/**
 * Created by lomo on 2017/3/13.
 */
public class javaStatic {
    protected int a = 10;
    final static int N = 1000;
    public String name = "Lomo";
    public static String sex = "Male";
//    public static int val = 88;

    void javaStatic() {
        System.out.println("这是构造函数！");
    }

    public static void javaStatic2() {
       System.out.println(N);
       System.out.println(sex);
       //System.out.println(name); //就会报错提示：非static的name在static的方法javaStatic中无法访问
    }

    public void getName() {
        System.out.println("非static的：" + this.name);
        System.out.println("static的：" + sex);
    }

    public void printvalue() {
        int val = 666;
//        try {
//            System.out.println(this.val);
//        }catch (Exception e) {
//            System.out.println(e);
//        }
        System.out.println(val);
    }


    //Test
    public static void main(String... args) {
        javaStatic jt = new javaStatic();
        jt.printvalue(); //88 , 通过对象获取类中的static属性值

//        jt.javaStatic2();  // 也是可以调用成功的

        javaStatic.javaStatic2();
        //1000
        //Male

    }

}

class T {
    public void set() {
        System.out.println(javaStatic.sex);


    }
}